import {request} from 'umi';
import {Source} from './data.d';
import {modulesUrl} from "@/assets/constant/modulesUrl";
import {getApiPrefix} from "@/assets/utils/utils";

/**
 * 测试数据源
 * @param params
 */
export async function testSource(params?: Source) {
  return request(getApiPrefix(modulesUrl.reportSource) + "/testSource", {
    method: 'POST',
    data: {
      ...params,
      method: 'post',
    },
  });
}

/**
 * 获取数据源的数据表列表名称
 * @param params
 */
export async function getTableNameList(id?: string) {
  return request(getApiPrefix(modulesUrl.reportSource) + "/getTableNameList", {
    params: {
      id: id
    }
  });
}

/**
 * 获取数据源
 * @param params
 */
export async function getDatabaseNameList(params?: Source) {
  return request(getApiPrefix(modulesUrl.reportSource) + "/getDatabaseNameList", {params});
}
